package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;

public class TOBINARY extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    if (paramArrayOfObject.length > 0)
    {
      Object localObject = paramArrayOfObject[0];
      if (localObject instanceof Integer)
      {
        int i = ((Integer)localObject).intValue();
        return Integer.toBinaryString(i);
      }
      if (localObject instanceof Number)
      {
        double d = ((Number)localObject).doubleValue();
        return Integer.toBinaryString((int)d);
      }
      return Primitive.ERROR_VALUE;
    }
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "TOBINARY(int): 将一个十进制整型数转换成二进制表示的字符串。\nint:表示需要进行转换的十进制整数。\n示例:\nTOBINARY(10)等于 \"1010\"。\nTOBINARY(20)等于 \"10100\"。";
  }

  public String getEN()
  {
    return "";
  }
}